import Vue from 'vue'
import Vuex from 'vuex'
import subExample from './sub-example'
Vue.use(Vuex)// vue的插件机制

// Vuex.Store 构造器选项
const store = new Vuex.Store({
  state: {
    hasLogin: false, // 判断用户是否登陆
    userCenterData: {}, // 个人中心页面数据
  },
  mutations: {
    login(state, provider) {
      state.hasLogin = true
      state.userCenterData = provider
      uni.setStorageSync('userCenterData', JSON.stringify(provider))
    },
    clearLoginInfo(state) {
      state.hasLogin = false
      state.userCenterData = {}
      uni.removeStorageSync('tokenid')
      uni.removeStorageSync('userCenterData')
    },
  },
  actions: {

  },
  modules: {
    subExample,
  },
})
export default store
